home *** CD-ROM | disk | FTP | other *** search
/ Aminet 23 / Aminet 23 (1998)(GTI - Schatztruhe)[!][Feb 1998].iso / Aminet / dev / misc / gms_dev.lha / GMSDev / Source / Asm / Screens / LoadPicture.s < prev    next >
Text File  |  1997-12-16  |  4KB  |  160 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;Name:      Load Picture
  3. ;Author:    Paul Manias
  4. ;Copyright: DreamWorld Productions (c) 1996-1997.  Freely distributable.
  5. ;
  6. ;This demo will load in a picture of any size/type and if it is larger than
  7. ;the screen width, it scrolls left and right.  This is easily possible due
  8. ;to the fact that GMS likes to fill in fields that have been set at zero
  9. ;on initialisation, which is great for loading/displaying things like
  10. ;pictures.
  11. ;
  12. ;The benefits of this will become more apparent when you want to do things
  13. ;like changing your graphics format from ECS to AGA and vice versa.  The
  14. ;benefits for the user are enormous (full graphical editing capabilities,
  15. ;if you program correctly).  And you don't even need to change a line of
  16. ;code!
  17.  
  18.     INCDIR    "GMSDev:Includes/"
  19.     INCLUDE    "dpkernel/dpkernel.i"
  20.  
  21. SPEED    =    2
  22.  
  23.     SECTION    "Demo",CODE
  24.  
  25. ;===========================================================================;
  26. ;                             INITIALISE DEMO
  27. ;===========================================================================;
  28.  
  29.     STARTDPK
  30.  
  31. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  32.     move.l    DPKBase(pc),a6
  33.     lea    PictureFile(pc),a0
  34.     moveq    #ID_PICTURE,d0
  35.     CALL    Load
  36.     move.l    d0,Picture
  37.     beq.s    .Exit
  38.  
  39.     moveq    #ID_SCREEN,d0
  40.     CALL    Get
  41.     move.l    d0,Screen
  42.     beq.s    .Exit
  43.  
  44.     move.l    Picture(pc),a0    ;a0 = Source structure.
  45.     move.l    Screen(pc),a1    ;a1 = Destination structure.
  46.     move.l    PIC_Bitmap(a0),a2
  47.     move.l    BMP_Data(a2),GS_MemPtr1(a1)
  48.     move.l    #HSCROLL,GS_Attrib(a1)
  49.     CALL    CopyStructure    ;>> = Copy Picture to Screen.
  50.  
  51.     move.l    Screen(pc),a0
  52.     sub.l    a1,a1
  53.     CALL    Init
  54.     tst.l    d0
  55.     beq.s    .Exit
  56.  
  57.     moveq    #ID_JOYDATA,d0    ;Get joydata structure for reading
  58.     CALL    Get    ;port 0.
  59.     move.l    d0,JoyData
  60.     beq.s    .Exit
  61.     move.l    d0,a0    ;Initialise the joydata structure.
  62.     sub.l    a1,a1
  63.     CALL    Init
  64.     tst.l    d0
  65.     beq.s    .Exit
  66.  
  67.     move.l    Screen(pc),a0
  68.     CALL    Display
  69.  
  70.     bsr.s    Main    ;Go and do the main routine.
  71.  
  72. .Exit    move.l    DPKBase(pc),a6
  73.     move.l    JoyData(pc),a0
  74.     CALL    Free
  75.     move.l    Screen(pc),a0
  76.     CALL    Free
  77.     move.l    Picture(pc),a0
  78.     CALL    Free
  79.     MOVEM.L    (SP)+,A0-A6/D1-D7
  80.     moveq    #ERR_OK,d0
  81.     rts
  82.  
  83. ;===========================================================================;
  84. ;                                MAIN LOOP
  85. ;===========================================================================;
  86.  
  87. Main:    move.l    SCRBase(pc),a6
  88.     move.l    Picture(pc),a2
  89.     moveq    #0,d7    ;d7 = Initialise fader.
  90.     moveq    #$000000,d2
  91.     moveq    #0,d3
  92.     move.l    PIC_Bitmap(a2),a5
  93.     move.l    BMP_AmtColours(a5),d4
  94.  
  95. .Fade1    move.l    Screen(pc),a0
  96.     CALL    scrWaitVBL
  97.     move.l    Screen(pc),a0    ;a0 = Screen to fade.
  98.     moveq    #2,d1    ;d1 = Speed of fade.
  99.     move.l    PIC_Palette(a2),a1    ;a1 = Palette we are fading to.
  100.     addq.w    #8,a1
  101.     move.w    d7,d0
  102.     CALL    scrColourToPalette    ;>> = Do the fade routine.
  103.     move.w    d0,d7    ;d7 = Fade counter.
  104.     bne.s    .Fade1    ;>> = If not finished, keep looping.
  105.  
  106.     moveq    #0,d2
  107. .loop    move.l    SCRBase(pc),a6
  108.     move.l    Screen(pc),a0
  109.     CALL    scrWaitAVBL
  110.  
  111.     move.l    Screen(pc),a0
  112.     move.l    GS_Bitmap(a0),a2
  113.     move.l    Picture(pc),a1
  114.     move.w    GS_Width(a0),d0    ;Only scroll the picture if is is
  115.     lsr.w    #3,d0    ;bigger than the actual screen.
  116.     cmp.w    BMP_Width(a2),d0
  117.     bge.s    .done
  118.  
  119.     tst.w    d2
  120.     bgt.s    .Right
  121. .Left    tst.w    GS_BmpXOffset(a0)
  122.     ble.s    .RRight
  123. .RLeft    moveq    #-SPEED,d2
  124.     bra.s    .scroll
  125. .Right    move.w    BMP_Width(a2),d0    ;d0 = PicWidth.
  126.     sub.w    #320,d0
  127.     cmp.w    GS_BmpXOffset(a0),d0    ;d0 = Is (Width-320 < PicOffset)?
  128.     ble.s    .RLeft
  129. .RRight    moveq    #SPEED,d2
  130. .scroll    add.w    d2,GS_BmpXOffset(a0)
  131.     CALL    scrMoveBitmap
  132.  
  133. .done    move.l    DPKBase(pc),a6
  134.     move.l    JoyData(pc),a0
  135.     CALL    Query
  136.     move.l    JoyData(pc),a0
  137.     move.l    JD_Buttons(a0),d0
  138.     btst    #JB_LMB,d0
  139.     beq.s    .loop
  140.     rts
  141.  
  142. ;===========================================================================;
  143. ;                                  DATA
  144. ;===========================================================================;
  145.  
  146. Screen:        dc.l  0
  147. Picture:    dc.l  0
  148. JoyData:    dc.l  0
  149.  
  150. PictureFile:    FILENAME "GMS:demos/data/PIC.Pic640x256"
  151.  
  152. ;===========================================================================;
  153.  
  154. ProgName:    dc.b  "Load Picture",0
  155. ProgAuthor:    dc.b  "Paul Manias",0
  156. ProgDate:    dc.b  "10 December 1997",0
  157. ProgCopyright:    dc.b  "DreamWorld Productions (c) 1996-1997.  Freely distributable.",0
  158. ProgShort:    dc.b  "Loads and displays any IFF picture.",0
  159.         even
  160.